package com.leyou.user.properties;

import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * @author linzx
 * @date 2020/3/29
 */
@ConfigurationProperties(prefix = "ly.user")
public class UserProperties {
    private String phonePrefix;
    private Long checkcodeLiveInMinutes;
    private String userExchangeForCode ;
    private String userRoutingkeyForCode ;


    public String getphonePrefix() {
        return StringUtils.isNoneBlank(phonePrefix) ? phonePrefix : DefaultUserProperties.PHONE_PREFIX ;
    }

    public void setphonePrefix(String phonePrefix) {
        this.phonePrefix = phonePrefix;
    }

    public Long getcheckcodeLiveInMinutes() {
        if (checkcodeLiveInMinutes == null || checkcodeLiveInMinutes < 0) {
            return  DefaultUserProperties.CHECKCODE_LIVE_IN_MINUTES;
        }
        return checkcodeLiveInMinutes ;
    }

    public void setcheckcodeLiveInMinutes(Long checkcodeLiveInMinutes) {
        this.checkcodeLiveInMinutes = checkcodeLiveInMinutes;
    }

    public String getUserExchangeForCode() {
        return StringUtils.isNoneBlank(userExchangeForCode) ? userExchangeForCode : DefaultUserProperties.USER_EXCHANGE_FOR_CODE;
    }

    public void setUserExchangeForCode(String userExchangeForCode) {
        this.userExchangeForCode = userExchangeForCode;
    }

    public String getUserRoutingkeyForCode() {
        return StringUtils.isNoneBlank(userRoutingkeyForCode) ? userRoutingkeyForCode : DefaultUserProperties.USER_ROUTINGKEY_FOR_CODE;
    }

    public void setUserRoutingkeyForCode(String userRoutingkeyForCode) {
        this.userRoutingkeyForCode = userRoutingkeyForCode;
    }
}
